<template>
  <view class="Nogoods" v-if="cart.length===0">
    <image src="../../static/cart_empty@2x.png" mode="widthFix"></image>
    <text>空空如也</text>
  </view>
  <view style="padding-bottom: 60px;" v-else>
    <Myaddress>></Myaddress>
    <view class="cart_info">
      <view class="cart_info_top">
        <uni-icons type="cart-filled" size="20"></uni-icons>
        <text>购物车</text>
      </view>
      <view class="cart_info_bottom">
        <uni-swipe-action>
          <block v-for="(item,index) in cart" :key="index">
            <uni-swipe-action-item :right-options="options" @click="deleteGoods(item)">
              <MyGoodsItem :goods="item" :showRadio="true"></MyGoodsItem>
            </uni-swipe-action-item>
          </block>
        </uni-swipe-action>
        
      </view>
    </view>
    <MySettlement></MySettlement>
  </view>
</template>

<script>
  import getTabBarBadge from "../../mixins/getTabBarBadge.js"
   import {mapState,mapMutations} from 'vuex'
  export default {
    data() {
      return {
       options: [{
       					text: '删除',
                style:{
                  backgroundColor:'#c00000'
                }
       				}]
      };
    },
    computed:{
      ...mapState('cartStore',['cart'])
    },

    mixins:[getTabBarBadge],
    methods:{
      deleteGoods(item){
        this.$store.commit('cartStore/deleteGoods',item.goods_id)
      }
    }
  }
</script>

<style lang="scss">
  .Nogoods{
    display: flex;
    flex-direction: column;
    align-items: center;
    image{
      margin-top: 200px;
      width: 100px;
    }
    text{
      font-size: 14px;
      color: #999;
      margin-top: 10px;
    }
  }
.cart_info_top{
  display: flex;
  align-items: center;
  height: 40px;
  padding: 0 10px;
  border-bottom: 1px solid #ccc;
  text{
    margin-left: 6rpx;
    font-size: 14px;
  }
}
</style>
